home *** CD-ROM | disk | FTP | other *** search
- program HodgePodge;
-
- {+----------------------------------------------------------------------------+
- | |
- | HodgePodge: An example Apple IIGS Desktop application |
- | |
- | Written in 65816 assembler and APW C by the Apple IIGS Tools Team |
- | Translated to TML Pascal by TML Systems, Inc. |
- | Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS" |
- | |
- | Copyright (c) 1986-87 by Apple Computer, Inc. |
- | Copyright (c) 1987 by TML Systems, Inc. |
- | |
- | ---------------------------------------------------------------------- |
- | |
- | This program and its derivatives are licensed only for |
- | use on Apple computers. |
- | |
- | Works based on this program must contain and |
- | conspicuously display this notice. |
- | |
- | This software is provided for your evaluation and to |
- | assist you in developing software for the Apple IIGS |
- | computer. |
- | |
- | This is not a distribution license. Distribution of |
- | this and other Apple software requires a separate |
- | license. Contact the Software Licensing Department of |
- | Apple Computer, Inc. for details. |
- | |
- | DISCLAIMER OF WARRANTY |
- | |
- | THE SOFTWARE IS PROVIDED "AS IS" WITHOUT |
- | WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
- | WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS |
- | FOR ANY PARTICULAR PURPOSE. THE ENTIRE RISK AS TO |
- | THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
- | YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND |
- | NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE) |
- | ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, |
- | REPAIR OR CORRECTION. |
- | |
- | Apple does not warrant that the functions |
- | contained in the Software will meet your requirements |
- | or that the operation of the Software will be |
- | uninterrupted or error free or that defects in the |
- | Software will be corrected. |
- | |
- | SOME STATES DO NOT ALLOW THE EXCLUSION |
- | OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY |
- | NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC |
- | LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS |
- | WHICH VARY FROM STATE TO STATE. |
- | |
- | ---------------------------------------------------------------------- |
- | |
- | Pascal UNIT "HP.PAS" : Main routine and tool init/shutdown routines |
- | |
- +----------------------------------------------------------------------------+}
-
-
-
- USES
- HPIntfData, {HodgePodge Apple IIGS Toolbox Interface Units}
- HPIntfProc,
- HPIntfPdos,
-
- Globals, {HodgePodge Code Units}
- Dialog,
- Font,
- Paint,
- Window,
- Print,
- Menu,
- Event;
-
-
-
- function StartUpTools : boolean;
-
- {Routine to start up the Apple IIGS toolbox. We attempt to start up all
- the managers that we need, checking each time if an error occurred during
- startup. True/false is returned by this routine depending on its success.
- If the RAM-based tools cannot be loaded, the user is prompted to install
- a system disk and is given the option of trying again or exitting. The
- latter option exits this procedure with a False result. Tool startup
- errors result in a call to the system death handler (the bouncing apple),
- with a code showing where we died as well as the actual tool error number.}
-
- var ToolRec : ToolTable;
- ParamBlock : FileRec;
-
- label 1; {Just for once, let's commit the cardinal sin of using the GOTO!}
-
- begin {of StartUpTools}
-
- StartUpTools := true; {Assume all is well at first}
-
- TLStartUp; {Init Tool Locator }
- CheckToolError (1);
-
- MyMemoryID := MMStartUp; {Init Memory Manager}
- MTStartUp; {Init Misc Tools }
- CheckToolError (2);
-
- {Allocate 10 pages of memory in bank 0 for use by GS Tools:
- 3 pages for QuickDraw,
- 1 page for Event Manager,
- 1 page for Control Manager,
- 1 page for Line Edit,
- 1 page for Menu Manager,
- 1 page for Standard File,
- 1 page for Print Manager,
- 1 page for Font Manager}
-
- ToolsZeroPage :=
- NewHandle (10 * 256, {Allocate 10 pages}
- MyMemoryID, {Process (user) ID}
- attrBank+attrFixed+attrLocked+attrPage, {Attributes}
- Ptr (0)); {Start in bank 0 }
- CheckToolError (3);
-
- QDStartUp
- (LoWord (ToolsZeroPage^), {Address of zpag # 3 }
- ScreenMode, {640 mode }
- MaxScan, {Horizontal line size}
- MyMemoryID); {Process (user) ID }
- CheckToolError (4);
-
- EMStartUp
- (LoWord (ToolsZeroPage^) + $300, {Address of zpag # 4 }
- 20, {Event queue size }
- 0, {X min clamp }
- MaxX, {X max clamp }
- 0, {Y min clamp }
- 200, {Y max clamp }
- MyMemoryID); {Process (user) ID }
- CheckToolError (5);
-
- {Give a message while we load RAM based tools:}
- MoveTo (20,20);
- SetBackColor (0);
- SetForeColor (15);
- DrawString ('One Moment Please...');
-
- ShowCursor;
-
- {Now load RAM based tools (and RAM patches to ROM tools!):}
- ToolRec.NumTools := 14;
- ToolRec.Tools[1].TSNum := 4; {QuickDraw II }
- ToolRec.Tools[1].MinVersion := 0;
- ToolRec.Tools[2].TSNum := 5; {Desk Manager }
- ToolRec.Tools[2].MinVersion := 0;
- ToolRec.Tools[3].TSNum := 6; {Event Manager }
- ToolRec.Tools[3].MinVersion := 0;
- ToolRec.Tools[4].TSNum := 14; {Window Manager }
- ToolRec.Tools[4].MinVersion := 0;
- ToolRec.Tools[5].TSNum := 15; {Menu Manager }
- ToolRec.Tools[5].MinVersion := 0;
- ToolRec.Tools[6].TSNum := 16; {Control Manager}
- ToolRec.Tools[6].MinVersion := 0;
- ToolRec.Tools[7].TSNum := 18; {QuickDraw Aux }
- ToolRec.Tools[7].MinVersion := 0;
- ToolRec.Tools[8].TSNum := 19; {Print Manager }
- ToolRec.Tools[8].MinVersion := 0;
- ToolRec.Tools[9].TSNum := 20; {Line Edit }
- ToolRec.Tools[9].MinVersion := 0;
- ToolRec.Tools[10].TSNum := 21; {Dialog Manager }
- ToolRec.Tools[10].MinVersion := 0;
- ToolRec.Tools[11].TSNum := 22; {Scrap Manager }
- ToolRec.Tools[11].MinVersion := 0;
- ToolRec.Tools[12].TSNum := 23; {Standard File }
- ToolRec.Tools[12].MinVersion := 0;
- ToolRec.Tools[13].TSNum := 27; {Font Manager }
- ToolRec.Tools[13].MinVersion := 0;
- ToolRec.Tools[14].TSNum := 28; {List Manager }
- ToolRec.Tools[14].MinVersion := 0;
-
- 1:
- ParamBlock.pathname := @'*/SYSTEM/TOOLS'; {Make sure tools avail}
- GET_FILE_INFO (ParamBlock);
- if toolErr <> 0 then
- if MountBootDisk = 1 then
- goto 1
- else begin
- StartUpTools := false;
- Exit;
- end;
-
- LoadTools (ToolRec); {Load the tools I need}
- CheckToolError (6);
-
- WindStartUp (MyMemoryID); {Init Window Manager }
- CheckToolError (7);
-
- RefreshDesktop (nil); {Draw the desktop }
-
- CtlStartUp {Init Control Manager}
- (MyMemoryID, {Process (user) ID }
- LoWord (ToolsZeroPage^) + $400); {Address of zpag # 5 }
- CheckToolError (8);
-
- LEStartUp {Init Line Edit }
- (LoWord (ToolsZeroPage^) + $500, {Address of zpag # 6 }
- MyMemoryID); {Process (user) ID }
- CheckToolError (9);
-
- DialogStartUp {Init Dialog Manager }
- (MyMemoryID); {Process (user) ID }
- CheckToolError (10);
-
- MenuStartUp {Init Menu Manager }
- (MyMemoryID, {Process (user) ID }
- LoWord (ToolsZeroPage^) + $600); {Address of zpag # 7 }
- CheckToolError (11);
-
- DeskStartUp; {Init Desk Manager }
- CheckToolError (12);
-
- ShowPleaseWait; {Put up dialog box }
-
- SFStartUp {Init Standard File }
- (MyMemoryID, {Process (user) ID }
- LoWord (ToolsZeroPage^) + $700); {Address of zpag # 8 }
- CheckToolError (13);
- SFAllCaps (true); {I want filenames in all caps}
-
- QDAuxStartUp; {Init QuickDraw Auxil}
- CheckToolError (14);
- WaitCursor; {Wristwatch cursor }
-
- FMStartUp {Init Font Manager }
- (MyMemoryID, {Process (user) ID }
- LoWord (ToolsZeroPage^) + $800); {Address of zpag # 9 }
- CheckToolError (15);
-
- ListStartUp; {Init List Manager }
- CheckToolError (16);
-
- PMStartUp {Init Print Manager }
- (MyMemoryID, {Process (user) ID }
- LoWord (ToolsZeroPage^) + $900); {Address of zpag # 10}
- CheckToolError (17);
-
- ScrapStartUp; {Init Scrap Manager }
- CheckToolError (18);
-
- HidePleaseWait; {Remove dialog box }
- InitCursor; {Normal arrow cursor }
-
- end; {of StartUpTools}
-
-
-
- procedure ShutDownTools;
-
- {Routine to shut down all the tools we used in reverse order of startup.
- Only tools which are currently active are shut down; this facilitates
- recovery from an error condition from StartUpTools.}
-
- begin {of ShutDownTools}
-
- {Put GrafOff call here if you don't want to see the windows close}
- DeskShutDown;
- if WindStatus <> 0 then
- HideAllWindows; {Close all windows only if OK! Takes some time.}
- ListShutDown;
- FMShutDown;
- ScrapShutDown;
- PMShutDown;
- QDAuxShutDown;
- SFShutDown;
- MenuShutDown;
- DialogShutDown;
- LEShutDown;
- CtlShutDown;
- WindShutDown;
- EMShutDown;
- if QDStatus <> 0 then
- GrafOff; {Back to text mode only if OK!}
- QDShutDown;
- MTShutDown;
- if MMStatus <> 0 then begin
- DisposeHandle (ToolsZeroPage); {Deallocate tool directpage space}
- MMShutDown (MyMemoryID); {Do this only if OK!}
- end;
- TLShutDown;
-
- end; {of ShutDownTools}
-
-
-
-
-
- BEGIN {of MAIN program HodgePodge}
-
- InitGlobals; { Initialze our globals, menus, etc. }
-
- if StartUpTools then begin { Initialize IIGS Tools }
- SetUpDefault; { Set up print dialog }
- SetUpMenus; { Set up menus }
- SetUpWindows; { Set up windows }
- MainEvent; { Use application }
- end;
-
- ShutDownTools; { Shut down IIGS Tools }
-
- END. {of MAIN program HodgePodge}
-